<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>暴风后台-角色列表</title>
<link rel="stylesheet" href="/public/images/admincp.css" type="text/css" media="all" />
<meta content="Comsenz Inc." name="Copyright" />
<script src="/public/include/js/formFilter.js" type="text/javascript"></script> 
</head>
<body>


<div id="append"></div>
<a class="othersoff" style="float:right;text-align:center" id="header_menu" onclick="headermenu(this)">菜单</a>
<ul id="header_menu_menu" style="display: none">
  <li><a href="/admin/user/create-role" target="main" class="tabon">添加新角色</a></li>
</ul>
<script type="text/javascript"> 
	function headermenu(ctrl) {
		ctrl.className = ctrl.className == 'otherson' ? 'othersoff' : 'otherson';
		var menu = document.getElementById('header_menu_body');
		if(!menu) {
			menu = document.createElement('div');
			menu.id = 'header_menu_body';
			menu.innerHTML = '<ul>' + document.getElementById('header_menu_menu').innerHTML + '</ul>';
			var obj = ctrl;
			var x = ctrl.offsetLeft;
			var y = ctrl.offsetTop;
			while((obj = obj.offsetParent) != null) {
				x += obj.offsetLeft;
				y += obj.offsetTop;
			}
			menu.style.left = x + 'px';
			menu.style.top = y + ctrl.offsetHeight + 'px';
			menu.className = 'togglemenu';
			menu.style.display = '';
			document.body.appendChild(menu);
		} else {
			menu.style.display = menu.style.display == 'none' ? '' : 'none';
		}
	}
</script>
<script type="text/javascript">
		function switchbtn(btn) {
			$('srchuserdiv').style.display = btn == 'srch' ? '' : 'none';
			$('srchuserdiv').className = btn == 'srch' ? 'tabcontentcur' : '' ;
			$('srchuserbtn').className = btn == 'srch' ? 'tabcurrent' : '';
			$('adduserdiv').style.display = btn == 'srch' ? 'none' : '';
			$('adduserdiv').className = btn == 'srch' ? '' : 'tabcontentcur';
			$('adduserbtn').className = btn == 'srch' ? '' : 'tabcurrent';
		}
	</script>
<div class="container">
  <br />
  <h3>角色列表</h3>
  <div class="mainbox">
    <form action="/admin/user/delete-role" onsubmit="return confirm('该操作不可恢复，您确认要删除这些用户吗？');" method="post">
      <input type="hidden" name="formhash" value="92809f92222c11a1">
      <table class="datalist fixwidth"  >
        <tr>
          <th><input type="checkbox" name="chkall" id="chkall" onclick="checkall()" class="checkbox" />
            <label for="chkall">删除</label></th>
          <th>角色名称</th>
          <th>描述</th>
          <th>注册日期</th>
          <th>操作</th>
        </tr>
		<?php
			if($this->roles){
				$roles = $this->roles->fetchAll(null , 'reg_date desc');
				foreach($roles as $role ){
		?>
		<tr>
          <td class="option">
          	<?php echo '<input type="checkbox" name="delete['.$role->id.']" value="'.$role->id.'" class="checkbox" />';?>
		  </td>
          <td>
          	<?php echo '<strong>'.$role->name.'</strong>'; ?>
		  </td>
          <td><?php echo ' <textarea name="rolenew['.$role->id.']">"'.$role->detail.'"</textarea>'; ?></td>
          <td>
			<?php echo '<strong>'.date('Y-m-d',$role->reg_date).'</strong>'; ?>
		  </td>
          <td>
          		<?php echo '<a href="/admin/user/edit-role/id/'.$role->id.'" class="tag_a">更新</a>'; ?>
				<?php echo $role->name=='superadmin'?'':'<a href="/admin/user/permission-role/id/'.$role->id.'">模块分配</a>'; ?>
		  </td>
        </tr>
		<?php		
				}
			}
		?>
  		        <tr class="nobg">
          <td><input type="submit" value="提 交" class="btn" /></td>
          <td class="tdpage" colspan="5"></td>
        </tr>
      </table>
    </form>
  </div>
</div>
</body>
</html>
<script type="text/javascript">
	$('.tag_a').click(function(event){
		var href = event.target.href;
		id = href.split("/id/")[1];
		
		var $textarea = $('textarea[name=rolenew\\['+id+'\\]]').val();
		event.target.href +="/detail/"+$textarea ;
	});
</script>

